#ifndef EXAMPLE_PLUGIN_H
#define EXAMPLE_PLUGIN_H

#include <QObject>
#include <QJsonObject>
#include <QJsonArray>
#include <QDateTime>
#include "../pluginsystem.h"

class ExamplePlugin : public QObject, public IAuditPlugin
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "com.pharmasoft.AuditPlugin/1.0" FILE "example_plugin.json")
    Q_INTERFACES(IAuditPlugin)

public:
    ExamplePlugin(QObject *parent = nullptr);
    ~ExamplePlugin();

    // IAuditPlugin interface
    QString pluginName() const override;
    QString pluginVersion() const override;
    QString pluginDescription() const override;
    QStringList requiredPermissions() const override;

    bool initialize(const QJsonObject &config) override;
    void shutdown() override;

    bool logEvent(const QString &userId, const QString &action, 
                  const QString &details, const QJsonObject &metadata = QJsonObject()) override;
    QJsonArray queryEvents(const QJsonObject &filter) const override;
    bool exportData(const QJsonObject &exportConfig) override;

    bool authenticateUser(const QString &username, const QString &password) override;
    bool hasPermission(const QString &userId, const QString &permission) const override;

private:
    bool m_initialized;
    QJsonObject m_config;
    QList<QJsonObject> m_eventLog; // Simple in-memory storage for demo
    
    // Helper methods
    bool matchesFilter(const QJsonObject &event, const QJsonObject &filter) const;
    void logToFile(const QString &message);
};

#endif // EXAMPLE_PLUGIN_H